package com.dhq.activemq;

import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;

@Component
public class TopicConsumerListener
{
    //topic模式的消费者
    @JmsListener(destination="${spring.activemq.topic-name}", containerFactory="topicListener")
    public void readActiveQueue(Message message) throws JMSException {
        MapMessage mapMessage =(MapMessage) message;
        //接受字符串类型
        String info = mapMessage.getString("info");
        System.out.println("topic接受到：" + info);
    }

    @JmsListener(destination="seckill.queue", containerFactory="topicListener")
    public void readActiveTop(Message message) throws JMSException {
        MapMessage mapMessage =(MapMessage) message;
        //接受字符串类型
        String info = mapMessage.getString("info");
        System.out.println("seckill.queue==topic接受到：" + info);
    }
}